<%@ taglib prefix="p" uri="/WEB-INF/tld/privilege.tld" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%     
	String path = request.getContextPath();     
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";     
%> 
<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <title>项目列表</title>
  <base href="<%=basePath%>"/>
  <%@ include file="../../list_include.jsp"%>
  <script language="JavaScript" type="text/javascript" src="<%=basePath%>js/my97/WdatePicker.js" defer="defer"></script>  
  <base target="_self" />
  
  <style type="text/css"> 
	fieldset,table,tr,td {margin:0; padding:0;}
	td {padding:0 5px 0 10px;}
	form label {font-weight:bold;}
    form input {width:200px;}
    #projectTable{margin:5px 0;}
  </style>

  <script type="text/javascript">
	$(document).ready(function() { 
       	$("#projectTable").tablesorter({theme:'green', widgets:['zebra', "resizable"]});
    	$.ajaxSetup ({ cache:false, async:false });
       	$("#btn_pageUp").click(function(){
			var curPage = $("#curPage").val();
			$("#curPage").val(parseInt(curPage) - 1);
			$("#projectForm").submit();
       	});
       	
       	$("#btn_pageDown").click(function(){
       		var curPage = $("#curPage").val();
			$("#curPage").val(parseInt(curPage) + 1);
			$("#projectForm").submit();
       	});
        
        $("#btn_search").click(function(){
            $("#curPage").val(1);
            $("#projectForm").submit();
        });
        
        $("#btn_clear").click(function(){
        	$("#name").val('');
            $("#status").val('');
        });

        $("#btn_change").click(function(){
            var page = parseInt($("#selectPage").val());
            var curPage = parseInt($("#curPage").val());
            if(curPage == page) return;
            $("#curPage").val(parseInt(page));
            $("#projectForm").submit();
        });
        
        $("#btn_insert").click(function(){
            var queryString = $("#itemForm").formSerialize();
            queryString = encodeURIComponent(queryString);
            location.href = "<%=basePath%>soft/project/insert.do";
        });
	});  
	
	function edit(id) {
        var queryString = $("#projectForm").formSerialize();
        queryString = encodeURIComponent(queryString);
        location.href = "<%=basePath%>soft/project/update.do?id=" + id + "&qs=" + queryString;
	}	
	function risk(id) {
        var queryString = $("#projectForm").formSerialize();
        queryString = encodeURIComponent(queryString);
        location.href = "<%=basePath%>soft/riskManager/list.do?projectId=" + id + "&qs=" + queryString;
	}	
	function personConf(id) {
        var queryString = $("#projectForm").formSerialize();
        queryString = encodeURIComponent(queryString);
        location.href = "<%=basePath%>soft/project/personConf.do?id=" + id + "&qs=" + queryString;
	}	
	
	function del(id) {
		if(confirm("确定删除该对象？") != 1) return;
		$.get("soft/project/delete.do", {id:id}, function(data) {
			var result = $.parseJSON(data);
			if(result.code == 1) {
				alert("删除成功!");
				$("#btn_search").click();
			} else {
				alert(result.msg);
			}
		});
	}
	
  </script>
 </head>

 <body>
  <div>
    <fieldset>
      <legend>查询条件：</legend>
      <form id="projectForm" method="get" action="soft/project/list.do">
        <table>
          <tr>
                <td><label for="name">项目名称：</label></td>
	            <td><input type="text" name="name" id="name"  style="width:150px;" value="${name }"/></td>
	            <td><label for="status">状态：</label></td>
	            <td>
	                <select name="status" id="status">
	                    <option value="">--选择状态--</option>
		                <c:forEach items="${dictItemList}" var="dict">
			                <option value="${dict.value}" <c:if test="${status == dict.value}">selected</c:if> >${dict.name}</option>
			            </c:forEach>
		             </select>
	            </td>
	            <td><input type="button" id="btn_search" name="btn_search" value="查询" style="width:80px;" /></td>
				<td><input type="button" id="btn_clear"  value="重置" style="width:80px;" /></td>
          </tr>
        <!--   <tr>
            <td><label for="starttime">起始时间：</label></td>
            <td>
                <input type="text" id="starttime" name="starttime" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',readOnly:true, maxDate:'#F{$dp.$D(\'endtime\')}'})" class="Wdate" value="${starttime}" />             
            </td>  
            <td><label for="endtime">终止时间：</label></td>
            <td>
                <input type="text" id="endtime" name="endtime" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',readOnly:true,minDate:'#F{$dp.$D(\'starttime\')}'})" class="Wdate" value="${endtime}" />             
            </td>  
            <td></td>          
          </tr> -->
        </table>
         <input type="hidden" name="curPage" id="curPage" value="${curPage}" />
		 <input type="hidden" name="totalPage" id="totalPage" value="${totalPage}" />
      </form>
    </fieldset>
  </div>
  <div>
  	<table id="projectTable" class="tablesorter">
		  <thead> 
		    <tr> 
	         <th>项目名称</th> 
	          <th>项目版本</th> 
		      <th>项目经理</th>
		      <th>客户</th>
		      <th>状态</th> 
		      <th>创建日期</th>
		      <th>操作</th> 
	 	    </tr> 
		  </thead>
		  <tbody>
		  <c:forEach items="${softProjectList}" var="pl" varStatus="status">
				<tr>
				  	  <td>${pl.name }</td>
				  	  <td>${pl.version }</td>
				      <td>${pl.cnName }</td>
				  	  <td>${pl.consumer }</td>
				  	  <c:forEach items="${dictItemList}" var="dict">
					  	  <c:if test="${dict.value == pl.status}">
					  	     <td>  ${dict.name}</td>
					  	  </c:if>
				      </c:forEach>
				  	  <td><fmt:formatDate value="${pl.createTime}" pattern="yyyy-MM-dd"/></td>
				  	  
				  	  <td>
				  	   <p:chkPri actionUrl="soft/project/view.do"><a href="soft/project/view.do?id=${pl.id}">查看</a></p:chkPri>
				  	   <p:chkPri actionUrl="soft/project/update.do">	<a href=# onclick="javascript:edit('${pl.id}'); return false;">修改</a></p:chkPri>
				  	   <a  onclick="javascript:personConf('${pl.id}'); return false;"  href="#">配备人员</a>
				  	   <p:chkPri actionUrl="soft/project/list.do"> <a href=#  onclick="javascript:risk('${pl.id}'); return false;" >风险管理</a></p:chkPri>
				  	  </td>
			  	</tr>
		  	</c:forEach>
		  	</tbody>
	  	</table>
  </div>
  <div >
      <div style="float:left;">
        <p:chkPri actionUrl="soft/project/insert.do"><input id="btn_insert" type="button" value="新增" /></p:chkPri>
      </div>

      <div style="text-align:right;">
        <c:if test="${curPage <= 1}"><input type="button" disabled="disabled" id="btn_pageUp" value="上一页"/></c:if>
        <c:if test="${curPage > 1}"><input type="button" id="btn_pageUp" value="上一页"/></c:if>
        <c:if test="${curPage >= totalPage}"><input type="button" id="btn_pageDown" disabled="disabled" value="下一页"/></c:if>
        <c:if test="${curPage < totalPage}"><input type="button" id="btn_pageDown" value="下一页"/></c:if>
                     共${totalPage}页/共${totalRecords}条
        <select id="selectPage" style="width: auto;">
            <c:forEach var="i" begin="1" end="${totalPage}">
                <option id="${i}" <c:if test="${i == curPage}">selected="selected"</c:if>>${i}</option>
            </c:forEach>
        </select>
        <input id="btn_change" type="button" value="转至" />
      </div>
  </div>
 </body>
</html>

